#!/bin/bash
if [ -z "$JAVA_HOME" ]; then
  JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.23.0.9-2.el7_9.x86_64d
fi

if [ -z "$JAVA_OPTS" ] ; then
  JAVA_OPTS="-Xms1536m -Xmx1536m -Dfile.encoding=UTF-8 -Dspring.config.location=datatrans-starter/src/main/resources/"
fi
export TZ=Asia/Shanghai
export LANG=C.UTF-8

pid=$(ps -ef |grep datatrans-starter.jar |grep -v grep |awk '{print $2}');
if [ ! -z "$pid" ] ; then
  echo "kill -15 $pid"
  kill -15 $pid
fi
sleep 10
pid=$(ps -ef |grep datatrans-starter.jar |grep -v grep |awk '{print $2}');
if [ ! -z "$pid" ] ; then
  echo "kill -15 $pid"
  kill -15 $pid
else
  echo 'application is stopped'
fi


${JAVA_HOME}/bin/java ${JAVA_OPTS} -jar datatrans-starter/target/datatrans-starter.jar